<template>
	<view class="main">
		<u-search bgColor="#fff" :showAction="false" placeholder="输入视频长尾词搜索" v-model="merge_keyword" @change="change"></u-search>
		<view class="list" v-for="(item,index) in list" :key="index">
			<view class="list-name flex align between">
				<view>{{item.merge_keyword}}</view>
				<view>{{item.keyword_type}}</view>
			</view>
			<view class="infos flex between">
				<view class="info-item">
					<view class="flex align between item">
						<view>视频描述</view>
						<view>{{item.tuiguangvideo.title}}</view>
					</view>
					<view class="flex align between item">
						<view>发布人</view>
						<view>{{item.nickname}}</view>
					</view>
					<view class="flex align between item">
						<view>价格（天）</view>
						<view>{{item.price}}</view>
					</view>
					<view class="flex align between item">
						<view>达标天数</view>
						<view>{{item.paiming_day}}</view>
					</view>
					<view class="flex align between item">
						<view>最后达标时间</view>
						<view>{{item.new_time}}</view>
					</view>
					<view class="flex align between item">
						<view>最后查询时间</view>
						<view>{{item.uptime}}</view>
					</view>
				</view>
				<view class="rank">
					<view>排名</view>
					<view>{{item.rank_num==0?'--':item.rank_num}}</view>
				</view>
			</view>
			<view class="trash flex align"><uni-icons color="#fff" type="trash" size="25"></uni-icons>删除</view>
		</view>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
		<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
	</view>
</template>

<script>
	import {
		videoRankIndex,
		rankDel
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				keyword: '',
				show: false,
				totalPage: 1,
				page: 0,
				offset: 20,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				merge_keyword:''
			};
		},
		onLoad(option) {
			this.getlist();
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods: {
			change() {
				this.page = 0
				this.list = []
				this.getlist()
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					group_id,
					type,
					merge_keyword,
					statusA,
					rank_id
				} = that;

				let obj = {
					menu_url: 'video_rank',
					limit: offset,
					offset: page,
					sort: 'id',
					order: 'desc',
					rank_status: 1,
					_: new Date().getTime(),
					filter: {},
					op: {}
					// filter:merge_keyword=='',
					// op:encodeURIComponent(JSON.stringify(filter))
				};
				if (merge_keyword != '') {
					obj.filter = JSON.stringify({
						"merge_keyword": merge_keyword.toString()
					})
					obj.op = JSON.stringify({
						"merge_keyword": 'LIKE'
					})
				}
				that.status = 'loading';
				if (totalPage > page) {
					let result = await videoRankIndex(obj);
					that.page = page + 1;
					if (result.total == 0) {
						that.empty = true;
						that.status = 'nomore';
						return;
					}
					that.empty = false;
					setTimeout(() => {
						that.status = 'loadmore';
					}, 500);
					that.list = list.concat(result.rows);
					that.totalPage = Math.ceil(result.total / offset);
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		padding: 13rpx 30rpx;

		.list {
			background: white;
			border-radius: 15rpx;
			margin-top: 20rpx;

			.list-name {
				background: #2D2D2D;
				border-radius: 15rpx 15rpx 0rpx 0rpx;
				padding: 26rpx 50rpx;

				view:nth-child(1) {
					color: #FFE9E0;
					font-size: 28rpx;
				}

				view:nth-child(2) {
					background: #00ACFF;
					color: white;
					padding: 1rpx 17rpx;
					border-radius: 40rpx;
				}
			}

			.infos {
				padding: 38rpx;

				.info-item {
					width: 60%;

					.flex {
						margin-bottom: 5rpx;

						view:nth-child(1) {
							font-size: 24rpx;
						}

						view:nth-child(2) {
							font-size: 20rpx;
							font-weight: bold;
						}
					}
				}

				.rank {
					text-align: center;

					view:nth-child(1) {
						font-size: 32rpx;
						font-weight: bold;
					}

					view:nth-child(2) {
						font-size: 32rpx;
						font-weight: bold;
						background: #FFCDB8;
						width: 128rpx;
						height: 68rpx;
						line-height: 68rpx;
						text-align: center;
						color: #D10000;
						border-radius: 10rpx;
						margin-top: 19rpx;
					}
				}
			}

			.trash {
				justify-content: center;
				background: #2D2D2D;
				color: white;
				font-size: 32rpx;
				font-weight: bold;
				padding: 15rpx 0;
				border-radius: 0 0 15rpx 15rpx;
			}
		}
	}
</style>